using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using DTO;
namespace BUS
{
   public class tbHoaDonBUS
    {
        public static int Insert(tbHoaDon hoadon)
        {
            tbHoaDonDAL hdDAL = new tbHoaDonDAL();
            return hdDAL.Insert(hoadon);
        }
       public static void Update(tbHoaDon hoadon)
        {
            tbHoaDonDAL hdDAl = new tbHoaDonDAL();
            hdDAl.Update(hoadon);
        }
       public static void UpdateTTGH(tbHoaDon hoadon)
       {
           tbHoaDonDAL hdDAL = new tbHoaDonDAL();
           hdDAL.UpdateTTGH(hoadon);
       }
        public static void Delete(int iD)
        {
            tbHoaDonDAL hdDAl = new tbHoaDonDAL();
            hdDAl.Delete(iD);
        }
       public static tbHoaDonCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbHoaDonDAL hdDAL = new tbHoaDonDAL();
            return hdDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
       public static tbHoaDonCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbHoaDonDAL haDAL = new tbHoaDonDAL();
            return haDAL.Get(cri.Criter, 0, 0, tbHoaDonColumns.mahd.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static tbHoaDon GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbHoaDonColumns.mahd.ToString(), Condition.EQUAL, iD);
            tbHoaDonDAL hdDAL = new tbHoaDonDAL();
            tbHoaDonCollection hdCollection = hdDAL.Get(cri.Criter, 0, 0, tbHoaDonColumns.mahd .ToString(), OrderDirection.ASC.ToString(), out total);
            if (hdCollection.Count > 0)
                return hdCollection[0];
            return null;
        }
       public static tbHoaDonCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbHoaDonDAL hdDAL = new tbHoaDonDAL();
            return hdDAL.Get(cri.Criter, 1, number, tbHoaDonColumns.mahd.ToString(), OrderDirection.DESC.ToString(), out total);
        }
       public static tbHoaDonCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbHoaDonDAL hdDAL = new tbHoaDonDAL();
            return hdDAL.Get(cri.Criter, 1, number, tbHoaDonColumns.mahd.ToString(), OrderDirection.DESC.ToString(), out total);
        }

       public static int CountByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbHoaDonColumns.mahd.ToString(), Condition.EQUAL, iD);
           tbHoaDonDAL dhDAL = new tbHoaDonDAL();
           tbHoaDonCollection dhCollection = dhDAL.Get(cri.Criter, 0, 0, tbHoaDonColumns.mahd.ToString(), OrderDirection.ASC.ToString(), out total);
           if (dhCollection.Count > 0)
               return total;
           return 0;
       }

        public static void UpdateTrangThai(int id)
        {
            
        }
    }
}
